package com.PopulateDB;

import java.util.Date;

import com.CMUBiS.util.Bid;

public class makeBid {
	private static double outBidFraction = 0.2;
	private static double outMaxBidFraction = 0.8;
	
	public static Bid makeBid(Bid previousBid){
		float newBid = (float) (previousBid.getMaxBid() * (Math.random()+outBidFraction));
		if(newBid < previousBid.getBid())
			newBid = previousBid.getBid()+0.01f;
		
		float newMaxBid = (float) (previousBid.getMaxBid() * (Math.random()+outMaxBidFraction));
		if(newMaxBid < newBid)
			newMaxBid = newBid;
		
		Date bidDate = new Date(previousBid.getBidDate().getTime() + (long)((System.currentTimeMillis() - previousBid.getBidDate().getTime())*Math.random()));
		
		return new Bid(-1,
				PopulateItems.getSellerID(CreateAll.noOfUsers),
				previousBid.getQuantity(),
				newBid,
				newMaxBid,
				bidDate,
				null);
	}
}
